<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=8">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta content="B2B电商平台" name="description"/>
	<meta content="B2B电商平台" name="keyword"/>
	
	<title>B2B电商平台.选点投放详情</title>
	<link rel="icon" href="include/images/icss.ico" type="image/x-icon" />
	<link rel="shortcut icon" href="include/images/icss.ico" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/global.css" />
	<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/style.css" />
	<link rel="stylesheet" type="text/css" href="<%=path%>/include/css/proManage.css" />
	<link rel="stylesheet" type="text/css" href="<%=path%>/include/pagination/page.css" media="all">
	
	<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>
	<script type="text/javascript" src="<%=path %>/include/js/icss.busin.js"></script>
	<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
	
	<script type="text/javascript" src="<%=path%>/include/pagination/jquery.pagination.js"></script>
	<script type="text/javascript" src="<%=path%>/include/pagination/init.js"></script>
	<script type="text/javascript" src="<%=path%>/include/js/doT.min.js"></script>
	
	<style type="text/css">
		body{background:#ebebeb;font-size: 14px;padding-left: 0px !important;}
		.table tr td {
				border-left: 1px solid #ddd;
				border-bottom: 1px solid #ddd;
				height: 33px;
			}
			
			.table tr th {
				border-left: 1px solid #ddd;
				font-weight: bold;
			}
	</style>
  	<script type="text/javascript">
	  	$(function(){
			_search();
		});
	
		var pagination;
		function _search() {
			var url = "<%=path%>/designatedSales/queryBuyerInfoList.do";
			var data = {
				queryCode : $("#queryCode").val(),
				queryName : $("#queryName").val()
			};
			pagination = _initPagination({'pageId':'pagination', 'url': url, 'data': data, 'rows': 5, 'callback':_initDataList});
		}
		
		function _initDataList(data) {
		 	var tpl = $('#dataTpl').html();
		 	/*if(data.rows.length<=5){
		 		$("#listTable").height("229px");
		 	}*/
			$('#tbody').html(doT.template(tpl)(data.rows));
		}

		function _checkAll(){
			var checked = $("#checkAll").is(':checked');
			var uuidStr = $("#uuidStr").val();
			if(checked){
				$("input[name='uuid']").each(function(){
					uuidStr += ","+this.value;
					$(this).attr("checked",'true');
				});
				$("#uuidStr").val(uuidStr);
			}else{
				$("input[name='uuid']").each(function(){
					$(this).removeAttr("checked");
				});
				$("#uuidStr").val("0");
			}
		}

		function _clickkInfo(id){
			if($("#"+id).is(':checked'))
				$("#uuidStr").val($("#uuidStr").val()+","+id);
			else
				$("#uuidStr").val($("#uuidStr").val().replace(","+id,""));
		}

		function _delBatch(){
			var uuidStr = $("#uuidStr").val();
			if(uuidStr=="0"){
				 alert("请选择批量删除的客户");
				 return ;
			}
			uuidStr = uuidStr.substr(2);
			_delClientInfo(uuidStr);
		}

		function _delClientInfo(uuid){
			$.ajax({
				type:"post",
				url:"<%=path%>/designatedSales/delDesignatedSalesInfo.do",
				dataType:"text",
				data:{
					productId : $("#productId").val(),
					uuidStr : uuid
				},
				success:function(data){
					if(data=="删除成功"){
						$("#checkAll").removeAttr("checked");
						$("#uuidStr").val("0");
						 _search();
					}
				}
			});
		}
  	</script>
  </head>
  
  <body>
    <div id="contentDiv">
    	<input type="hidden" id="codeName" name="codeName">
    	<div class="title_div" style="display: none;">
	   		<div class="titleCss title_2"></div>
	   	<hr color="#ebebeb" height="0.1px" style="margin-top:13px"/>
	   	</div>
	   	<div style="margin: 0px 0px;background:#fff;font-size: 12px;padding-bottom: 5px;">
   			<div class="divCss_title" style="padding: 10px 0px 0px 20px;font-size: 14px;">
   				<input type="hidden" id="productId" name="productId" value="${productId }"/>
				客户简码:<input id="queryCode" name="queryCode" placeholder="请输入客户简码/许可证号/登录名"   
						    	style="width: 180px;height: 24px; padding-left: 3px;font-size: 12px;" value="" type="text" />&nbsp;
  				客户姓名:<input id="queryName" name="queryName" placeholder="请输入客户姓名" style="font-size: 12px;height: 24px;width: 180px;padding-left: 3px" type="text" />&nbsp;
				<button class="cxx_btn" type="button" style="height: 25px;border-radius: 2px;" onclick="_search()">查询</button>
				<button class="cxx_btn2" type="button" style="height: 25px;border-radius: 2px;" onclick="_delBatch()">批量删除</button></div>
   			<div style="padding:10px 20px 0px 20px;height: 256px;">
	   			<div class="row-fluid dataTables_wrapper" >
					<table id="listTable"
						class="table table-hover table-nomargin table-bordered usertable dataTable"
						style="border-spacing: 0;width: 100%;">
						<thead>
							<tr class="trBgd"
								style="background-color: #eee;text-align: center; height: 31px; border: 1px solid #ddd; white-space: nowrap; background-position: 0 -123px; line-height: 30px; font-weight: bold;">
								<th>
									<input id="checkAll" type="checkbox" name="checkAll" onclick="_checkAll()" value="" star="3" mainpro="">
									<input type="hidden" id="uuidStr" name="uuidStr" value="0"/>
								</th>
								<th>
									序号
								</th>
								<th>
									客户名称
								</th>
								<th>
									客户简码/许可证号/登录名
								</th>
								<th>
									电话
								</th>
								<th style="border-right: 1px solid #ddd;">
									操作
								</th>
							</tr>
						</thead>
						<tbody id="tbody" style="font-size: 13px">
						</tbody>
					</table>
					<div class="dataTables_paginate paging_full_numbers">
						<span id="innerHtml"> </span>
					</div>
					<div id="pagination"></div>
					<div>
						<div style="height: 30px;"></div>
						<!-- 分类列表div结束 -->
						<div class="clear"></div>
					</div>
				</div>
   			</div>
    </div>
  </body>
  <script id="dataTpl" type="text/template">
		{{ for (var i = 0; i < it.length; i ++) { }}  
		{{     var row = it[i]; }}
			<tr style='line-height: 20px;white-space: nowrap;'>
				<td style='text-align:center;vertical-align: middle;width:6%;'>
					<input id='{{=row.UUID}}' onclick="_clickkInfo('{{=row.UUID}}')" type="checkbox" name="uuid" value="{{=row.UUID}}" star="3" mainpro="">
				</td>
				<td style='text-align:center;vertical-align: middle;width:6%;'>{{=row.PID}}</td>
				<td style='text-align:left;vertical-align: middle;width:43%;'>&nbsp;{{=row.USER_NAME}}</td>
				<td style='text-align:left;vertical-align: middle;width:20%;'>&nbsp;{{=row.LICENCE_NO}}</td>
				<td style='text-align:center;vertical-align: middle;width:15%;'>{{=row.TEL}}</td>
				<td style='text-align:center;vertical-align: middle;width:10%;border-right: 1px solid #ddd;'>
					<a href="javascript:_delClientInfo('{{=row.UUID}}')">删除</a>
				</td>
		     </tr>
		{{ } }}
	</script>
</html>
